package com.mfangsoft.zhuangjialong.integration.seller.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mfangsoft.zhuangjialong.app.seller.model.SellerEntity;
import com.mfangsoft.zhuangjialong.common.model.Page;
import com.mfangsoft.zhuangjialong.common.model.ResponseMessage;
import com.mfangsoft.zhuangjialong.common.utils.SysConstant;
import com.mfangsoft.zhuangjialong.integration.seller.service.SellerService;

@Controller
@RequestMapping("/server")
public class SellerController {

	
	@Autowired
	private SellerService sellerService;
	/**
	 * 根据条件筛选卖家列表
	 * @param page
	 * @return 
	 */
	@RequestMapping(value="/getTuiguangSeller",method=RequestMethod.POST)
	@ResponseBody	
	public Page<Map<String,Object>> getTuiguangSeller(@RequestBody Page<Map<String,Object>> page){
		
		return sellerService.getTuiguangSellerForPage(page);
	}
	/**
	 * 获取一个
	 * @param sellerEntity
	 * @return
	 */
	@RequestMapping(value="/getoneseller",method=RequestMethod.POST)
	@ResponseBody
	 public ResponseMessage<Map<String,Object>> getOneSeller(@RequestBody SellerEntity sellerEntity){
		
		ResponseMessage<Map<String,Object>> message = new ResponseMessage<Map<String,Object>>();
		Map<String,Object> map = sellerService.getOneSeller(sellerEntity);
		
		if(map !=null && map.size() >0){
			message.setCode(SysConstant.SUCCESS_CODE);
			message.setMessage(SysConstant.SUCCESS_MSG);
			message.setResult(map);
		}else{
			message.setCode(SysConstant.FAILURE_CODE);
			message.setMessage(SysConstant.FAILURE_MSG);
		}
		 return message;
	}
	/**
	 * 根据条件筛选卖家列表
	 * @param page
	 * @return
	 */
	@RequestMapping(value="/getSeller",method=RequestMethod.POST)
	@ResponseBody	
	public Page<Map<String,Object>> getSellerForPage(@RequestBody Page<Map<String,Object>> page){
		
		return sellerService.getSellerForPage(page);
	}
}
